from app import create_app, db
from app.models import User
from datetime import datetime

def create_structure():
    app = create_app()
    with app.app_context():
        # 删除所有表
        db.drop_all()
        # 创建所有表
        db.create_all()
        
        # 创建管理员用户
        admin = User(
            username='admin',
            email='admin@example.com',
            is_admin=True,
            real_name='管理员',
            phone='13800138000',
            status='active',
            last_login=datetime.utcnow(),
            created_at=datetime.utcnow()
        )
        admin.set_password('123456')
        
        # 创建测试用户
        user = User(
            username='test',
            email='test@example.com',
            is_admin=False,
            real_name='测试用户',
            phone='13900139000',
            status='active',
            created_at=datetime.utcnow()
        )
        user.set_password('123456')
        
        db.session.add(admin)
        db.session.add(user)
        db.session.commit()
        
        print('数据库结构创建成功！')
        print('管理员账号：admin')
        print('管理员密码：123456')
        print('测试账号：test')
        print('测试密码：123456')

if __name__ == '__main__':
    create_structure() 